package com.ruoyi.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.share.domain.ShareOrderForm;
import com.ruoyi.share.service.IShareOrderFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单Controller
 *
 * @author ruoyi
 * @date 2021-11-16
 */
@RestController
@RequestMapping("/api/shoreform")
public class ShareOrderFormController extends BaseController
{
    @Autowired
    private IShareOrderFormService shareOrderFormService;

    /**
     * 分页查询商品列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareOrderForm shareOrderForm , @RequestParam Integer pageNum, @RequestParam Integer pageSize)
    {
        List<ShareOrderForm> list = shareOrderFormService.selectShareOrderListPage(shareOrderForm,pageNum,pageSize);
        return getDataTable(list);
    }

    /**
     * 导出订单列表
     */
    @GetMapping("/export")
    public AjaxResult export(ShareOrderForm shareOrderForm)
    {
        List<ShareOrderForm> list = shareOrderFormService.selectShareOrderFormList(shareOrderForm);
        ExcelUtil<ShareOrderForm> util = new ExcelUtil<ShareOrderForm>(ShareOrderForm.class);
        return util.exportExcel(list, "订单数据");
    }

    /**
     * 获取订单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shareOrderFormService.selectShareOrderFormById(id));
    }

    /**
     * 新增订单
     */
    @PostMapping
    public AjaxResult add(@RequestBody ShareOrderForm shareOrderForm)
    {
        return toAjax(shareOrderFormService.insertShareOrderForm(shareOrderForm));
    }

    /**
     * 修改订单
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ShareOrderForm shareOrderForm)
    {
        return toAjax(shareOrderFormService.updateShareOrderForm(shareOrderForm));
    }

    /**
     * 删除订单
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shareOrderFormService.deleteShareOrderFormByIds(ids));
    }
}
